package fnord.illuminati.card.winconditions;

import java.util.LinkedList;
import java.util.Queue;

import fnord.illuminati.card.GroupCard;
import fnord.illuminati.card.WinCondition;
import fnord.network.server.Player;

public class BavarianWinCondition extends WinCondition {
	private static final long serialVersionUID = 3503153514604505089L;
	
	private final int _powerToWin = 35;
	
	@Override
	public boolean hasWon(Player p) {
		Queue<GroupCard> cards = new LinkedList<GroupCard>();
		cards.add(p.getIlluminati());
		
		int power = 0;
		while (!cards.isEmpty()) {
			GroupCard current = cards.poll();
			cards.addAll(current.getChildren());
			power += current.getPower();
		}
		
		if (power>=_powerToWin)
			return true;
		else
			return false;
	}
}
